Add compute_switch_flows() for zero-impedance bus-bus switches#2956
Open
pehlert wants to merge 1 commit intoe2nIEE:developfrom
Open
Add compute_switch_flows() for zero-impedance bus-bus switches#2956pehlert wants to merge 1 commit intoe2nIEE:developfrom
pehlert wants to merge 1 commit intoe2nIEE:developfrom
Conversation
After runpp(), bus-bus switches with z_ohm=0 have NaN in res_switch because Pandapower fuses their buses into a single internal node. This makes it impossible to determine the power flow through individual bus couplers, bus-section switches, or similar zero- impedance switching devices. This commit adds a new toolbox function compute_switch_flows(net) that populates res_switch (p_from_mw, q_from_mvar, p_to_mw, q_to_mvar, i_ka, loading_percent) for these switches using a post-hoc nodal balance approach: 1. Identify fused-bus groups from _pd2ppc_lookups["bus"] 2. Calculate net local injection at each bus from res_* tables (loads, generators, shunts, wards, and outgoing branch flows) 3. Build the zero-impedance switch tree within each fused group 4. DFS from leaves to root to accumulate subtree demand and derive individual switch flows The function raises ValueError if zero-impedance switches form a cycle within a fused group, since the flow split is physically indeterminate without impedance information. Switches with z_ohm > 0 are not modified, as they already have results from the Newton-Raphson solver. Also adds documentation (toolbox.rst, switch.rst, CHANGELOG.rst) and 17 tests covering single couplers, chains, branching trees, cycle detection, sign convention, cross-validation, and loading percent.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2956 +/- ##
===========================================
+ Coverage 71.99% 72.06% +0.06%
===========================================
Files 352 352
Lines 38305 38447 +142
===========================================
+ Hits 27577 27706 +129
- Misses 10728 10741 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Add
compute_switch_flows()to populateres_switchfor zero-impedance bus-bus switchesMotivation
After
runpp(), bus-bus switches withz_ohm=0(the default) always haveNaNinres_switch, since Pandapower fuses adjacent buses into a single PPC node. This makes it impossible to determine power flow through individual bus couplers, bus-section switches, or breaker-and-a-half arrangements.Knowing cross-coupler flows is a common requirement in SCADA/EMS applications: real-time systems measure these flows via current transformers on the coupler path, and any simulation or state estimation that drives an SLD needs to reproduce them. Detailed substation models from CGMES/CIM imports represent the full busbar topology with explicit switching devices, and users expect
res_switchto reflect the actual flow through each device.Setting
z_ohmto a small positive value is the existing workaround, but it causes convergence failures on large networks. We observed this consistently with 12,000+ bus-bus switches -- the Jacobian becomes near-singular from the many very-low-impedance branches.Solution
New toolbox function
compute_switch_flows(net), called after a converged load flow:res_*tables (loads, generators, shunts, wards, outgoing branches).ValueErrorif a cycle is detected (flow split is physically indeterminate without impedance).p_from_mw,q_from_mvar,p_to_mw,q_to_mvar,i_ka, andloading_percentintonet.res_switch.Switches with
z_ohm > 0are not modified.Usage